Skip to content

feat(remote-providers): DM-5782: add remote provider endpoints to the client - #90

Open
AaronBarnes07 wants to merge 5 commits into
mainfrom
DM-5782-remote-providers
Open

AaronBarnes07 wants to merge 5 commits into
mainfrom
DM-5782-remote-providers

Conversation

@AaronBarnes07

Copy link
Copy Markdown
Collaborator

Summary

Adds remote providers to the client.
A remote provider is a service, hosted by the customer, that the remote_http mask sends values to over HTTP.
The client can now create, list, get, update, delete and test them, following the pattern of the other admin entities.

What changed

Model (datamasque/client/models/remote_provider.py)

  • RemoteProvider with its options as enums: CertificateVerification, RemoteProviderAuthType, TokenBodyFormat, RemoteProviderMethod.
  • RemoteProviderParameter, RemoteProviderTestResult, the RemoteProviderId type and ParameterValue for test parameters.
  • Defaults match the server's defaults.
  • certificate_file accepts a FileId or an uploaded CertificateFile, the same way run and discovery models accept a connection object or its ID.
  • The server stores "no token body format" as a blank string; the model reads it as None and writes None back as a blank string.
  • id, has_secret, created_date and modified_date are read-only and are never sent.

Client (datamasque/client/remote_providers.py, mixed into DataMasqueClient)

  • list_remote_providers, get_remote_provider, get_remote_provider_by_name
  • create_remote_provider, update_remote_provider, create_or_update_remote_provider
  • delete_remote_provider_by_id_if_exists, delete_remote_provider_by_name_if_exists
  • test_remote_provider(id, value, params): sends one value and returns the provider's output or the error.

Docs and history: both new modules are in the API reference, and HISTORY.rst has a 1.7.0 entry.

Decisions for the reviewer

  • The secret is write-only. The server never returns it; has_secret says whether one is saved.
    secret is left out of the request body when it is None, so an update without a secret keeps the saved one.
    It is also left out of the model's repr, so it does not show up in logs or tracebacks.
  • The server refuses some updates without a new secret: a change of the base URL or the token URL, or turning certificate verification to none.
    The client does not check this itself; the server's 400 comes back as DataMasqueApiError, and the docstrings say so.
  • Administrator only. Every endpoint answers other users with 403; the client adds no role check of its own.
  • List is not paginated, matching the server endpoint, so get_remote_provider_by_name filters the full list.
  • test_remote_provider takes any mapping of parameters, so callers can pass a TypedDict or a read-only mapping.

These endpoints need a DataMasque server version that has remote providers.

How it was tested

On the branch head (0219daa):

  • tests/test_remote_providers.py: 20 new tests against mocked HTTP, covering each call, the defaults, the secret kept out of repr, a create that sends the secret, an update without a secret that leaves it out of the body, an update that sends a new one, the blank token body format, a server field error raising DataMasqueApiError, a refused create that does not log the secret, the delete no-op paths, and a test call returning both an output and an error.
  • make test: 837 passed.
  • make lint (ruff check, ruff format check, mypy): clean.
  • Sphinx docs build with warnings as errors: clean.

@AaronBarnes07 AaronBarnes07 self-assigned this Nov 23, 2026
Comment on lines +143 to +147
response = self.make_request(
"POST",
f"/api/remote-providers/{remote_provider_id}/test/",
data={"value": value, "params": dict(params or {})},
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a non-2xx response, make_request passes data to _raise_for_status, which logs Request data was: ... at ERROR. _redact_sensitive hides only keys that contain password, secret, token, key or credential, so value and params are logged in clear. The docstring says the value is not saved or logged, and a caller can pass a real value here.

Call make_request(..., require_status_check=False), then self._raise_for_status(response) with no request_data, as _delete_if_exists does.

Add a test that a 400 from the test endpoint leaves the value and the params out of the log.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to require_status_check=False then _raise_for_status(response) with no request data, and added a test that a 400 from the test endpoint keeps the value and params out of the log.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants